Sum all the numbers in a listΒΆ
Write a python function to sum all the numbers in a list.
Sample List:
(8, 2, 3, 0, 7)
Expected output:
20
def sum(numbers):
total = 0
for x in numbers:
total += x
return total
# test
print(sum((8, 2, 3, 0, 7)))
Output:
20